package com.atguigu.mapper;

import com.atguigu.bean.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

// @Mapper
public interface EmployeeMapper {
    @Select("select * from employee")
    public List<Employee> getEmps();

    @Select("select * from employee where id=#{id}")
    public Employee getEmpById(Integer id);

    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into employee(last_name,email,gender,d_id) values(#{lastName},#{email},#{gender},#{dId})")
    public int insertEmp(Employee Emp);

    @Update("update employee set last_name=#{lastName},email=#{email},gender=#{gender},d_id=#{dId} where id=#{id}")
    public int updateEmp(Employee Emp);

    @Delete("delete from employee where id=#{id}")
    public int deleteEmp(Integer id);

    @Select("select * from employee where last_name=#{name}")
    public Employee getEmpByName(String name);
}
